﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AddressBook.Master" AutoEventWireup="true" CodeBehind="ManageLocations.aspx.cs" Inherits="AddressBook.Web.ManageLocations" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContentPlaceHolder" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainPaneContentPlaceHolder" runat="server">
	<div class="LocationList">
		<div class="ListHeader">
			Locations
			<div style="float: right;">
				<asp:ImageButton ID="LocationListAddLocationButton" runat="server" ImageUrl="~/Images/add_16.png" AlternateText="Add Family" ToolTip="Add Family" />
			</div>
		</div>
    <asp:Panel ID="LocationErrorsPanel" runat="server" style="padding: 5px;" Visible="false">
      <asp:Label ID="LocationErrorMessage" runat="server" ForeColor="Red" />
    </asp:Panel>
		<asp:ListView ID="ManageLocationsLocationList" runat="server" 
									OnItemCommand="ManageLocationsLocationList_ItemCommand" 
									OnItemEditing="ManageLocationsLocationList_ItemEditing" 
									OnItemDeleting="ManageLocationsLocationList_ItemDeleting" >
			<LayoutTemplate>
				<ul style="list-style-image: none; list-style-type: none; width: 300px; padding-left: 0px; margin: 0px;">
					<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
				</ul>
			</LayoutTemplate>
			<ItemTemplate>
				<li style="padding: 4px 4px; line-height: 16px;">
					<asp:ImageButton ID="EditButton" runat="server" CommandName="Edit" CommandArgument='<%# Eval("Id") %>' ImageUrl="~/Images/edit_location_16.png" AlternateText="Edit Location" ToolTip="Edit Location" ImageAlign="Bottom" />
					<asp:ImageButton ID="DeleteButton" runat="server" CommandName="Delete" CommandArgument='<%# Eval("Id") %>' ImageUrl="~/Images/delete_16.png" AlternateText="Delete Location" ToolTip="Delete Location" ImageAlign="Bottom" />
					<asp:Literal ID="LocationName" runat="server" Text='<%# Eval("Name") %>' />
					<cc1:ConfirmButtonExtender ID="DeleteButtonConfirmExtender" runat="server" 
																		 ConfirmText="Are you sure you want to delete this location?" 
																		 TargetControlID="DeleteButton" />
				</li>
			</ItemTemplate>
			<AlternatingItemTemplate>
				<li style="background-color: #BCDFF2; padding: 4px 4px; line-height: 16px;">
					<asp:ImageButton ID="EditButton" runat="server" CommandName="Edit" CommandArgument='<%# Eval("Id") %>' ImageUrl="~/Images/edit_location_16.png" AlternateText="Edit Location" ToolTip="Edit Location" ImageAlign="Bottom" />
					<asp:ImageButton ID="DeleteButton" runat="server" CommandName="Delete" CommandArgument='<%# Eval("Id") %>' ImageUrl="~/Images/delete_16.png" AlternateText="Delete Location" ToolTip="Delete Location" ImageAlign="Bottom" />
					<asp:Literal ID="LocationName" runat="server" Text='<%# Eval("Name") %>' />
					<cc1:ConfirmButtonExtender ID="DeleteButtonConfirmExtender" runat="server" 
																		 ConfirmText="Are you sure you want to delete this location?" 
																		 TargetControlID="DeleteButton" />
				</li>
			</AlternatingItemTemplate>
			<EmptyDataTemplate>
				<asp:Literal ID="EmptyList" runat="server" Text="You have not yet created any locations" />
			</EmptyDataTemplate>
		</asp:ListView>
	</div>
	
	<!--Add Location Popup Panel-->
	<cc1:ModalPopupExtender ID="AddLocationPanelPopupExtender" runat="server" 
													TargetControlID="LocationListAddLocationButton" 
													PopupControlID="ManageLocationsAddLocationPanel" 
													CancelControlID="AddLocationCloseButton" 
													BackgroundCssClass="modalBackground" />
  <asp:Panel ID="ManageLocationsAddLocationPanel" runat="server" CssClass="PopupPanel" style="display: none;" > 
		<div class="PopupHeader">
			Add Location
			<div style="float: right">
				<asp:ImageButton ID="AddLocationSaveButton" runat="server" ImageUrl="~/Images/save_16.png" AlternateText="Save Location" ToolTip="Save Location" OnClick="AddLocationSaveButton_Click" ValidationGroup="AddLocation" style="margin-right: 4px;" />
			  <asp:ImageButton ID="AddLocationCloseButton" runat="server" ImageUrl="~/Images/close_16.png" AlternateText="Close" ToolTip="Close" />
			</div>
		</div> 
    <table border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td colspan="2"><asp:ValidationSummary ID="AddLocationValidationSummary" runat="server" ValidationGroup="AddLocation" /></td>
			</tr>
      <tr>
        <td><asp:Literal ID="AddLocationNameLiteral" runat="server" Text="Name" /></td>
        <td>
          <asp:TextBox ID="AddLocationNameTextBox" runat="server" MaxLength="50" />
          <asp:RequiredFieldValidator ID="AddLocationNameRequiredValidator" runat="server" 
																			ErrorMessage="You must enter a location name" 
																			ControlToValidate="AddLocationNameTextBox"
																			Display="None" 
																			ValidationGroup="AddLocation" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="AddLocationAddressLine1Literal" runat="server" Text="Street Address" /></td>
        <td>
          <asp:TextBox ID="AddLocationAddressLine1TextBox" runat="server" MaxLength="60" />
          <asp:RequiredFieldValidator ID="AddLocationAddressLine1RequiredValidator" runat="server" 
																			ErrorMessage="You must enter a street name" 
																			ControlToValidate="AddLocationAddressLine1TextBox" 
																			Display="None" 
																			ValidationGroup="AddLocation" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="AddLocationAddressLine2Literal" runat="server" Text="Appt #" /></td>
        <td>
          <asp:TextBox ID="AddLocationAddressLine2TextBox" runat="server" MaxLength="60" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="AddLocationCityLiteral" runat="server" Text="City" /></td>
        <td>
          <asp:TextBox ID="AddLocationCityTextBox" runat="server" MaxLength="30" />
          <asp:RequiredFieldValidator ID="AddLocationCityRequiredValidator" runat="server" 
																			ErrorMessage="You must enter a city" 
																			ControlToValidate="AddLocationCityTextBox" 
																			Display="None" 
																			ValidationGroup="AddLocation" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="AddLocationStateLiteral" runat="server" Text="State" /></td>
        <td>
          <asp:DropDownList ID="AddLocationStateDropDown" runat="server" />
          <asp:RequiredFieldValidator ID="AddLocationStateRequiredValidator" runat="server" 
																			ErrorMessage="You must select a state" 
																			ControlToValidate="AddLocationStateDropDown" 
																			Display="None" 
																			ValidationGroup="AddLocation" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="AddLocationPostalCodeLiteral" runat="server" Text="Zip Code" /></td>
        <td>
          <asp:TextBox ID="AddLocationPostalCodeTextBox" runat="server" MaxLength="5" />
          <asp:RequiredFieldValidator ID="AddLocationPostalCodeRequiredValidator" runat="server" 
																			ErrorMessage="You must enter a zip code" 
																			ControlToValidate="AddLocationPostalCodeTextBox" 
																			Display="None" 
																			ValidationGroup="AddLocation" />
        </td>
      </tr>
    </table>
  </asp:Panel>
  
  <!--Edit Location Popup Panel-->
	<cc1:ModalPopupExtender ID="EditLocationPanelPopupExtender" runat="server" 
													TargetControlID="HiddenAction" 
												  PopupControlID="EditLocationPanel" 
													CancelControlID="EditLocationCloseButton" 
													BackgroundCssClass="modalBackground" />
	<asp:LinkButton ID="HiddenAction" runat="server" style="visibility: hidden;" />
  <asp:Panel ID="EditLocationPanel" runat="server" CssClass="PopupPanel" style="display: none;" > 
		<div class="PopupHeader">
			Edit Family
			<div style="float: right">
				<asp:ImageButton ID="EditLocationSaveButton" runat="server" ImageUrl="~/Images/save_16.png" AlternateText="Save Location" ToolTip="Save Location" OnClick="EditLocationSaveButton_Click" ValidationGroup="EditLocation" style="margin-right: 4px;" />
			  <asp:ImageButton ID="EditLocationCloseButton" runat="server" ImageUrl="~/Images/close_16.png" AlternateText="Close" ToolTip="Close" />
			</div>
		</div> 
    <table border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td colspan="2"><asp:ValidationSummary ID="EditLocationValidationSummary" runat="server" ValidationGroup="EditLocation" /></td>
			</tr>
      <tr>
        <td><asp:Literal ID="EditLocationPopupNameLiteral" runat="server" Text="Name" /></td>
        <td>
					<asp:HiddenField ID="EditLocationIdField" runat="server" />
          <asp:TextBox ID="EditLocationNameTextBox" runat="server" MaxLength="50" />
          <asp:RequiredFieldValidator ID="EditLocationNameRequiredValidator" runat="server" 
																			ErrorMessage="You must enter a location name" 
																			ControlToValidate="EditLocationNameTextBox"
																			Display="None" 
																			ValidationGroup="EditLocation" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="EditLocationAddress1Literal" runat="server" Text="Street Address" /></td>
        <td>
          <asp:TextBox ID="EditLocationAddress1TextBox" runat="server" MaxLength="60" />
          <asp:RequiredFieldValidator ID="EditLocationAddress1RequiredValidator" runat="server" 
																			ErrorMessage="You must enter a street name" 
																			ControlToValidate="EditLocationAddress1TextBox" 
																			Display="None" 
																			ValidationGroup="EditLocation" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="EditLocationAddress2Literal" runat="server" Text="Appt #" /></td>
        <td>
          <asp:TextBox ID="EditLocationAddress2TextBox" runat="server" MaxLength="60" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="EditLocationCityLiteral" runat="server" Text="City" /></td>
        <td>
          <asp:TextBox ID="EditLocationCityTextBox" runat="server" MaxLength="30" />
          <asp:RequiredFieldValidator ID="EditLocationCityRequiredValidator" runat="server" 
																			ErrorMessage="You must enter a city" 
																			ControlToValidate="EditLocationCityTextBox" 
																			Display="None" 
																			ValidationGroup="EditLocation" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="EditLocationStateLiteral" runat="server" Text="State" /></td>
        <td>
          <asp:DropDownList ID="EditLocationStateDropDown" runat="server" />
          <asp:RequiredFieldValidator ID="EditLocationStateRequiredValidator" runat="server" 
																			ErrorMessage="You must select a state" 
																			ControlToValidate="EditLocationStateDropDown" 
																			Display="None" 
																			ValidationGroup="EditLocation" />
        </td>
      </tr>
      <tr>
        <td><asp:Literal ID="EditLocationPostalCodeLiteral" runat="server" Text="Zip Code" /></td>
        <td>
          <asp:TextBox ID="EditLocationPostalCodeTextBox" runat="server" MaxLength="5" />
          <asp:RequiredFieldValidator ID="EditLocationPostalCodeRequiredValidator" runat="server" 
																			ErrorMessage="You must enter a zip code" 
																			ControlToValidate="EditLocationPostalCodeTextBox" 
																			Display="None" 
																			ValidationGroup="EditLocation" />
        </td>
      </tr>
    </table>
  </asp:Panel>
</asp:Content>
